<template>
  <div class="risk">
    <eagle-tab-page-list
      url="/DangerCheckTaskDetail/GetHiddenDangerPageData"
      :params="params"
      @initActive="_initActive"
      @initList="_initList"
      ref="eagleTabPageList"
    >
      <eagle-cell class="card" v-for="(item, index) in list" :key="index">
        <template v-if="active === 0">
          <div class="warn_item">
            <div @click="goToDetail(item)">
              <div class="warn_header">
                <div>{{ item.EquipmentName }}</div>
                <eagle-tag
                  v-if="item.ExpireDays < 0"
                  class="warn_tag"
                  type="warning"
                  >剩{{ Math.abs(item.ExpireDays) }}</eagle-tag
                >
                <eagle-tag
                  v-if="item.ExpireDays > 0"
                  class="warn_tag"
                  type="warning"
                  >逾期{{ Math.abs(item.ExpireDays) }}</eagle-tag
                >
              </div>
              <div class="dep_sort">
                <div>
                  {{ index + 1 }}、隐患描述：{{ item.HiddenDangerDesc }}
                </div>
              </div>

              <eagle-row gutter="20" class="dep_sort">
                <eagle-col span="12">
                  <img
                    src="@/assets/Images/AppIcon/icon_list_area.png"
                    alt=""
                  />{{ item.HiddenDangerArea }}</eagle-col
                >
              </eagle-row>
              <eagle-row gutter="20" class="dep_sort">
                <eagle-col span="10">
                  <img
                    src="@/assets/Images/AppIcon/icon_list_post.png"
                    alt=""
                  />{{ item.CreateChnName }}</eagle-col
                >
                <eagle-col span="14">
                  <img
                    src="@/assets/Images/AppIcon/icon_list_org.png"
                    alt=""
                  />{{ item.CreateDate }}</eagle-col
                >
              </eagle-row>
            </div>
          </div>
        </template>
        <template v-if="active === 1">
          <div class="warn_item">
            <div @click="goDetail(item)">
              <div class="warn_header">
                <div>{{ item.EquipmentName }}</div>
                <eagle-tag
                  v-if="item.ExpireDays < 0"
                  class="warn_tag"
                  type="warning"
                  >剩{{ Math.abs(item.ExpireDays) }}</eagle-tag
                >
                <eagle-tag
                  v-if="item.ExpireDays > 0"
                  class="warn_tag"
                  type="warning"
                  >逾期{{ Math.abs(item.ExpireDays) }}</eagle-tag
                >
              </div>
              <div class="dep_sort">
                <div>
                  {{ index + 1 }}、隐患描述：{{ item.HiddenDangerDesc }}
                </div>
              </div>

              <eagle-row gutter="20" class="dep_sort">
                <eagle-col span="12">
                  <img
                    src="@/assets/Images/AppIcon/icon_list_post.png"
                    alt=""
                  />{{ item.HiddenDangerArea }}</eagle-col
                >
              </eagle-row>
              <eagle-row gutter="20" class="dep_sort">
                <eagle-col span="10">
                  <img
                    src="@/assets/Images/AppIcon/icon_list_org.png"
                    alt=""
                  />{{ item.CreateChnName }}</eagle-col
                >
                <eagle-col span="14">
                  <img
                    src="@/assets/Images/AppIcon/icon_list_org.png"
                    alt=""
                  />{{ item.CreateDate }}</eagle-col
                >
              </eagle-row>
            </div>
          </div>
        </template>
        <template v-if="active === 2">
          <div class="warn_item">
            <div @click="goToDetail(item)">
              <div class="warn_header">
                <div>{{ item.EquipmentName }}</div>
                <eagle-tag
                  v-if="item.ExpireDays < 0"
                  class="warn_tag"
                  type="warning"
                  >剩{{ Math.abs(item.ExpireDays) }}</eagle-tag
                >
                <eagle-tag
                  v-if="item.ExpireDays > 0"
                  class="warn_tag"
                  type="warning"
                  >逾期{{ Math.abs(item.ExpireDays) }}</eagle-tag
                >
              </div>
              <div class="dep_sort">
                <div>
                  {{ index + 1 }}、隐患描述：{{ item.HiddenDangerDesc }}
                </div>
              </div>
              <eagle-row gutter="20" class="dep_sort">
                <eagle-col span="12">
                  <img
                    src="@/assets/Images/AppIcon/icon_list_area.png"
                    alt=""
                  />{{ item.HiddenDangerArea }}</eagle-col
                >
              </eagle-row>
              <eagle-row gutter="20" class="dep_sort">
                <eagle-col span="10">
                  <img
                    src="@/assets/Images/AppIcon/icon_list_post.png"
                    alt=""
                  />{{ item.CheckTaskName }}</eagle-col
                >
                <eagle-col span="14">
                  <img
                    src="@/assets/Images/AppIcon/icon_list_org.png"
                    alt=""
                  />{{ item.CreateDate }}</eagle-col
                >
              </eagle-row>
            </div>
            <eagle-divider />
            <eagle-button
              class="ml-10 mb-5"
              style="float: right; height: 30px"
              size="small"
              type="default"
              @click="goApprove2(item)"
              >审批历史
            </eagle-button>
          </div>
        </template>
      </eagle-cell>
    </eagle-tab-page-list>
  </div>
</template>

<script>
export default {
  data() {
    return {
      params: [
        {
          title: "待制定措施",
          dataType: "ToBeFormulated",
          badge: false,
        },
        {
          title: "待整改",
          dataType: "ToBeCorrectived",
          badge: false,
        },
        {
          title: "已整改",
          dataType: "BeCorrectived",
          badge: false,
        },
      ],
      list: [],
      active: 0,
    };
  },
  created() {},
  methods: {
    _initActive(active) {
      this.active = active;
    },
    _initList(list) {
      this.list = list;
    },
    goToDetail(item) {
      this.$router.push({
        // path: "/Danger/JGFormulatedDetail",
        path: "/Danger/FormulatedDetail",
        query: { id: item.ID },
      });
    },
    goDetail(item) {
      this.$router.push({
        // path: "/Danger/DangerCheckDetailView",
        path: "/Danger/MyCorrectivedDetail",
        query: { id: item.ID },
      });
    },
    getFile(equipmentCode) {
      this.$router.push({
        path: "/Equipment/safetyfile",
        query: { equipmentCode: equipmentCode },
      });
    },
    // 编辑设备信息
    edit(equipmentCode) {
      this.$router.push({
        path: "/Equipment/Edit",
        query: { equipmentCode: equipmentCode },
      });
      this.$router.push("");
    },
    // 设备检验
    editCheck(equipmentCode) {
      this.$router.push({
        path: "/Equipment/editcheck",
        query: { equipmentCode: equipmentCode },
      });
    },
    goApprove2(item) {
      console.log("1111111111");
      this.$router.push("/Danger/DangerCheckPlanApprove?recordID=" + item.ID);
    },
  },
};
</script>

<style lang="less" scoped>
.risk {
  background-color: #e8f1f8;
  .info_search {
    padding: 10px;
    border-radius: 5px !important;
    .van-field__control {
      background-color: #ffffff !important;
    }
  }
}
.all_dep {
  background-color: #ffffff;
}

.warn_item {
  /*margin-bottom: 10px;*/
  // padding: 10px 0 10px 10px;
  border-radius: 5px;
  position: relative;
}
.warn_header {
  display: flex;
  justify-content: space-between;
  position: relative;
  margin-bottom: 10px;
  .warn_tag {
    position: absolute;
    right: 0;
    top: 0;
    border-radius: 26.64rem 0 0 26.64rem;
  }
}
.dep_sort {
  // display: flex;
  // flex-wrap: wrap;
  // margin-bottom: 5px;
  img {
    height: 15px;
    width: 15px;
    margin-right: 5px;
  }
}
.dep_btm {
  display: flex;
  justify-content: flex-end;
  .btm_item {
    display: flex;
    align-items: center;
    img {
      height: 15px;
      width: 15px;
      margin-right: 5px;
    }
  }
}
</style>
